var _o53;
var cc__decorate = __decorate;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var cc__decorator = cc._decorator;
var ccp_ccclass = cc__decorator.ccclass;
var ccp_property = cc__decorator.property;
var def_LoadManager = _o53 = /* */function () {
  function _ctor() {
    babel_classCallCheck(this, _ctor);
    this.loading = false;
    this.loadList = [];
    this.completedCount = 0;
    this.totalCount = 0;
    this.tempcompletedCount = 0;
    this.onAllResProgress = null;
  }
  return babel_createClass(_ctor, [{
    key: "loadSub",
    value: function loadSub(e) {
      return new Promise(function (e, t) {
        try {
          e("success");
        } catch (n) {
          t("fail");
        }
      });
    }
  }, {
    key: "addLoadTask",
    value: function addLoadTask(e, t, n, _o54) {
      this.totalCount += t;
      this.loadList.push({
        url: e,
        totalCount: t,
        onProgress: _o54,
        callback: n
      });
      this.loadRes();
    }
  }, {
    key: "loadRes",
    value: function loadRes() {
      var _this54 = this;
      if (this.loadList.length > 0 && 0 == this.loading) {
        var _e28 = this.loadList.shift();
        this.loading = true;
        cc.loader.loadRes(_e28.url, function (t, n, _o55) {
          _e28.onProgress && _e28.onProgress(t, n, _o55);
          _this54.tempcompletedCount = t;
          _this54.onAllResProgress && _this54.onAllResProgress(_this54.completedCount + _this54.tempcompletedCount, _this54.totalCount, "正在准备场景，");
        }, function () {
          _this54.loading = false;
          _this54.completedCount += _this54.tempcompletedCount;
          _this54.tempcompletedCount = 0;
          _e28.callback && _e28.callback();
          _this54.loadRes();
        });
      }
    }
  }, {
    key: "addEventListen",
    value: function addEventListen(e) {
      this.onAllResProgress = e;
    }
  }], [{
    key: "getInstance",
    value: function getInstance() {
      null == this._instance && (this._instance = new _o53());
      return this._instance;
    }
  }]);
}();
def_LoadManager = _o53 = cc__decorate([ccp_ccclass], def_LoadManager);
exports.default = def_LoadManager;